load("@rules_oci//oci:defs.bzl", "oci_image")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

pkg_tar(
    name = "multipath",
    srcs = [":multipath.conf"],
    mode = "0600",
    package_dir = "/etc",
)

pkg_tar(
    name = "get-version",
    srcs = ["//:get-version"],
    package_dir = "/",
)

pkg_tar(
    name = "entrypoint",
    srcs = [":entrypoint.sh"],
    mode = "0700",
    package_dir = "/",
)

oci_image(
    name = "version-container",
    base = "//:passwd-image",
    tars = select({
        "@io_bazel_rules_go//go/platform:linux_arm64": [
            ":multipath",
            ":entrypoint",
            "//rpm:pr-helper_aarch64",
            ":get-version",
        ],
        "//conditions:default": [
            ":multipath",
            ":entrypoint",
            "//rpm:pr-helper_x86_64",
            ":get-version",
        ],
    }),
)

oci_image(
    name = "pr-helper-image",
    base = ":version-container",
    entrypoint = ["/usr/bin/qemu-pr-helper"],
    visibility = ["//visibility:public"],
)
